#include "ScientificPlot.h"
#include "ScientificPlotEvent.h"
#include <qcustomplot.h>

ScientificPlot::ScientificPlot(QWidget* parent, PLOT_TYPE plot_type)
    : SessionItemWidget(parent), m_plot_type(plot_type), m_event(new ScientificPlotEvent(this))
{
}

ScientificPlot::~ScientificPlot() = default;

double ScientificPlot::xAxisCoordToPixel(double axis_coordinate) const
{
    return customPlot()->xAxis->coordToPixel(axis_coordinate);
}

double ScientificPlot::yAxisCoordToPixel(double axis_coordinate) const
{
    return customPlot()->yAxis->coordToPixel(axis_coordinate);
}

double ScientificPlot::pixelToXaxisCoord(double pixel) const
{
    return customPlot()->xAxis->pixelToCoord(pixel);
}

double ScientificPlot::pixelToYaxisCoord(double pixel) const
{
    return customPlot()->yAxis->pixelToCoord(pixel);
}

void ScientificPlot::setMouseTrackingEnabled(bool enable)
{
    m_event->setMouseTrackingEnabled(enable);
}

bool ScientificPlot::axesRangeContains(double xpos, double ypos) const
{
    return customPlot()->xAxis->range().contains(xpos)
           && customPlot()->yAxis->range().contains(ypos);
}
